﻿//===============================================================================
//	LuaGlueMap.cpp
//	LUA -> C++ 地图相关接口管理器
//===============================================================================

#include "LuaGlue.h"
#include "../share/LuaGlueCommon.h"

#include "LuaManager.h"
#include "../share/user_define.h"

#include "ManagerHelper.h"
#include "Map.h"

//-------------------------------------------------------------------------------
int32_t Monster_GetMonsterInfoFromTable(lua_State * ls)
{
	_safe_guard_begin;

	MacroCheckParamCount(ls, 2, "Monster_GetMonsterInfoFromTable");

	uint32_t _pos = 0;
	MacroIsNumber(ls, ++_pos, "Monster_GetMonsterInfoFromTable");
	MacroIsNumber(ls, ++_pos, "Monster_GetMonsterInfoFromTable");

	_pos = 0;
	int32_t _idx = MacroGetIntegerArgument(ls, ++_pos);
	int32_t _type = MacroGetIntegerArgument(ls, ++_pos);

	MonsterSetInfo* _msi = nullptr;
	bool _is_ok = MonsterTablePtr->GetMonsterInfoByIdx(_idx, &_msi);
	if (!_is_ok)
	{
		return 0;
	}

	_safe_check(_msi);

	double _ret_val = 0.0;

	if (1 == _type)
	{
		_ret_val = _msi->GetLevel();
	}
	else if (2 == _type)
	{
		_ret_val = _msi->GetFightProperty().GetHp();
	}
	else if (3 == _type)
	{
		//_ret_val = _msi->m_hp_grow;
		//_ret_val=_msi->GetFightProperty()
		//todo:jin
		_ret_val = _msi->GetLvHp();
	}

	MacroPushNumber(ls, _ret_val);
	return 1;

	_safe_guard_end;

	return 0;
}

//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------